import javafx.scene.layout.Priority;

import java.util.*;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: ling
 * Date: 2022-06-21
 * Time: 10:50
 */
public class Test{
    public static int sum1=0;
    public static int sum2=0;
    private int a=0;
    public static void main(String[] args) throws InterruptedException {
        long startTime=System.currentTimeMillis();
        int[] arr=new int[1000_0000];
        Random r=new Random();
        for(int i=0;i<1000_0000;i++) {
            arr[i]=r.nextInt(100)+1;
        }
        int sum=0;
        Thread t1=new Thread(()->{

            for(int i=0;i<1000_0000;i+=2) {
                sum1+=arr[i];
            }
        });
        Thread t2=new Thread(()->{
            for(int i=1;i<1000_000;i+=2) {
                sum2+=arr[i];
            }
        });
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println("总和："+(sum1+sum2));
        long end=System.currentTimeMillis();
        System.out.println("时间"+(end-startTime));


    }
}

